#ifndef TCPSERVER_H
#define TCPSERVER_H

#include "database.h"

#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMainWindow>
#include <QPushButton>
#include <QtNetwork>

namespace Ui {
class TcpServer;
}

class TcpServer : public QMainWindow
{
    Q_OBJECT

public:
    explicit TcpServer(QWidget *parent = 0);
    ~TcpServer();

protected:
    void startService();
    void stopService();

private slots:
    void btn_start_server_clicked();

    void acceptConnection();

    void receiveData();

    void displayError(QAbstractSocket::SocketError);

private:

    QListWidget *contentListWidget;
    QLabel *portLabel;
    QLineEdit *portLineEdit;
    QPushButton *btn_start_server;
    QGridLayout *mainLayout;

    Ui::TcpServer *ui;
    QTcpSocket *tcpSocket;
    QTcpServer *tcpServer;

    Database *db;

    bool isStarted = false;

};

#endif // TCPSERVER_H
